package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.article.query.DestinationQuery;
import cn.wolfcode.luowowo.article.service.IDestinationService;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Administrator on 2019/7/8.
 */
@Controller
@RequestMapping("/destination")
public class DestinationController {
    @Reference
    private IDestinationService destinationService;
    @RequestMapping("list")
    public String list(Model model, @ModelAttribute("qo") DestinationQuery qo) {
        model.addAttribute("pageInfo", destinationService.query(qo));
        //这里需要查询所有目的地,也就是所有区域下面的所有城市或国家

        model.addAttribute("toasts",destinationService.getToasts(qo.getParentId()));
        return "destination/list";
    }
    @RequestMapping("changeHotValue")
    @ResponseBody
    public Object changeHotValue(Long id,Boolean hot){
        destinationService.changeHotValueById(id,hot);
        return new AjaxResult();
    }
    @RequestMapping("delete")
    @ResponseBody
    public Object delete(Long id){
        destinationService.delete(id);
        return new AjaxResult();
    }
    @RequestMapping("setInfo")
    @ResponseBody
    public Object setInfo(Long id,String info){
        destinationService.setInfo(id,info);
        return new AjaxResult();
    }
}
